package com.xiaoying.server.publish.utils;

import redis.clients.jedis.Jedis;

public class RedisUtil {
    
    private static Jedis redis;
    
    private static Jedis redisBackup;
    
    /*
     * XIAOYING FileInfo队列 在Redis中的key名称
     */
    public static byte[] KEY_XIAOYING_FILEINFO_QUEUE = "xiaoying_file_info".getBytes();
    
    /*
     * XIAOYING UploadResult队列 在Redis中的key名称
     */
    public static byte[] KEY_XIAOYING_UPLOAD_RESULT_QUEUE = "xiaoying_file_upload_result".getBytes();
    
    /**
     * 小影  上传文件信息备份 Redis前缀
     */
    public static final String PREFIX_XY_BACKUP_UPLOAD_FILEINFO = "XY_BACKUP_UPLOAD_FILEINFO_";
    
    public RedisUtil() {
        
    }
   
    /**
     * 获取redis客户端
     * @return
     */
    public synchronized static Jedis getRedisInstance() {
        if(redis==null) {
            redis = new Jedis ("127.0.0.1",6379);   //连接redis
        }
        return redis;
    }
   
    /**
     * 获取Redis队列Backup客户端
     * @return
     */
    public synchronized static Jedis getBackupRedisInstance() {
        if(redisBackup==null) {
        	redisBackup = new Jedis ("127.0.0.1",6379);   //连接redis
        }
        return redisBackup;
    }
   
    
    
    /**
     * 获取独立Redis客户端连接
     * @return
     */
    public static Jedis getNewRedisClient() {
    	return new Jedis ("127.0.0.1",6379);   //连接redis
    }
    

}
